<?php
	class news_commentControl extends skymvc{
		function __construct(){
			parent::__construct();
		}
		
		public function onDefault(){
			$start=get('per_page','i');
			$limit=24;
			 
			$where=" status<11 AND  siteid=".SITEID;
			$order="newsid DESC";
			$rscount=true;
			$url=APPADMIN."?m=news_comment";
			$option=array(
				"where"=>$where,
				"start"=>$start,
				"limit"=>$limit,
				"order"=>$order
			);
			$data=M("news_comment")->select($option,$rscount);
			
			if($data){
				foreach($data as $v){
					$uids[]=$v['userid'];
				}
				$us=M("user")->getUserByIds($uids); 
				
				
				foreach($data as $k=>$v){
					
					$v['nickname']=$us[$v['userid']]['nickname'];
					$v['user_head']=$us[$v['userid']]['user_head'];		
					
					$data[$k]=$v;
				}
			}
			$per_page=$start+$limit;
			$per_page=$per_page>=$rscount?0:$per_page;
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->goassign(array(
				"data"=>$data,
				"pagelist"=>$pagelist,
				"per_page"=>$per_page
			));
			$this->smarty->display("news_comment/index.html");
		}
		
		public function onDelete(){
		 
			$id=get('id','i');
			$row=M("news_comment")->selectRow("id=".$id);
			if($row['siteid']!=SITEID){
				$this->goAll("暂无权限",1);
			}
			M("news_comment")->update(array(
				"status"=>11
			),"id=".$id);
			$this->goAll("删除成功");
		}
		
		
	}
?>